package cn.thoughtworks.school.contract;

import cn.thoughtworks.school.Application;
import cn.thoughtworks.school.services.AmazonClientService;
import cn.thoughtworks.school.services.JenkinsService;
import com.github.database.rider.core.api.configuration.DBUnit;
import com.github.database.rider.core.api.dataset.DataSet;
import com.github.database.rider.spring.api.DBRider;
import io.restassured.module.mockmvc.RestAssuredMockMvc;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;

@Ignore
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
@ActiveProfiles("test")
@Transactional
@DBRider
@DBUnit(caseSensitiveTableNames = true)
@DataSet("homeworkquiz.yml")
public class SingleStackProgrammingQuizBase {

    @Autowired
    private WebApplicationContext wac;
    @MockBean
    private JenkinsService jenkinsService;
    @MockBean
    private AmazonClientService amazonClientService;

    @Before
    public void setup() {
        Mockito.when(jenkinsService.triggerSingleStackProgrammingQuizJob(Mockito.anyString(), Mockito.anyString()))
                .thenReturn(null);
        Mockito.when(amazonClientService.uploadFile(Mockito.any(MultipartFile.class), Mockito.anyString()))
                .thenReturn("nice");
        RestAssuredMockMvc.webAppContextSetup(wac);
    }
}
